package com.tmall.tmall.controller;

import com.tmall.tmall.pojo.Product;
import com.tmall.tmall.pojo.ProductRt;
import com.tmall.tmall.pojo.Result;
import com.tmall.tmall.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/productList")
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping
    public Result getByTypeId(@PathVariable Integer typeId){
        List<ProductRt> list = productService.getByCid(typeId);
        return Result.success(list);
    }
    @GetMapping("/list")
    public Result list(){
        List<ProductRt> list = productService.selectAll();
        return Result.success(list);
    }
}
